import { Master } from 'message-lite';
import { services } from './impl';

export const master = new Master({
  listenMessage(fn: (message: any) => void) {
    IDP.Miniapp.view.defaultFrame.onMessageReceive((data, origin) => {
      fn(data);
    });
  },
  unListenMessage(fn: (message: any) => void) {},
  createSender(origin: any) {
    return (message: any) => {
      IDP.Miniapp.view.defaultFrame.postMessage(message);
    };
  },
});

master.addService(services);
